{extend name="frame/base" /}
{block name="body"}
<table>
    <thead>
    <tr>
        <th width="280">分类名称</th>
        <th>分类类型</th>
        <th>分类别名</th>
        <th width="200">排序</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="data"}
    {eq name="data['upid']" value="0"}
    <tr id="c_{$data['id']}" class="top">
        <td style="text-align: left;text-indent: 40px;">{$data['name']}</td>
        <td>{$data['type_text']}</td>
        <td>{$data['alias']}</td>
        <td style="text-align: left;text-indent: 40px;">{$data['sort']}</td>
        <td><a href="/admin/cate/edit?id={$data['id']}">编辑</a><a href=""
                                                                 onclick="del('{$data['id']}');return false">删除</a>
        </td>
    </tr>
    {else/}
    <tr class="sub" upid="{$data['upid']}">
        <td style="text-align: left;text-indent: 60px;">├{$data['name']}</td>
        <td>{$data['type_text']}</td>
        <td>{$data['alias']}</td>
        <td style="color: #F00;text-align: left;text-indent: 40px;">├{$data['sort']}</td>
        <td><a href="/admin/cate/edit?id={$data['id']}">编辑</a><a href=""
                                                                 onclick="del('{$data['id']}');return false">删除</a>
        </td>
    </tr>
    {/eq}

    {/volist}
    </tbody>
</table>
<script>
    $(function () {
        $(".sub").each(function () {
            var upid = $(this).attr("upid")
            if ($(".sub_" + upid).length == 0) {
                $("#c_" + upid).after("<tr class='sub_" + upid + "'>" + $(this).html() + "</tr>")
            }
            else{
                $(".sub_" + upid+":last").after("<tr class='sub_" + upid + "'>" + $(this).html() + "</tr>")
            }

        })
        $(".sub").hide();
    })

    function del(id) {
        if (confirm("请确认要删除此记录"))
            window.location.href = "/admin/cate/delete?id=" + id
    }
</script>
<br>
<a href="/admin/cate/edit" class="button">添加分类</a>
{/block}
